package beautiful.butterfly.drds.data_exchange.util;

import java.util.HashSet;
import java.util.List;
import java.util.Set;


public final class ListUtil
{


    public static void makeSureNoValueDuplicate(List<String> stringList)
    {
        if (null == stringList || stringList.isEmpty())
        {
            throw new IllegalArgumentException("您提供的作业配置有误, List不能为空.");
        }

        if (1 == stringList.size())
        {
            return;
        } else
        {
            Set<String> set = new HashSet<String>(stringList);
            if (set.size() != stringList.size())
            {
                throw new IllegalArgumentException("字段重复");
            }
        }
    }


    public static boolean checkIfValueSame(List<Boolean> booleanList)
    {
        if (null == booleanList || booleanList.isEmpty())
        {
            throw new IllegalArgumentException("您提供的作业配置有误, List不能为空.");
        }

        if (1 == booleanList.size())
        {
            return true;
        } else
        {
            Boolean firstValue = booleanList.get(0);
            for (int i = 1, size = booleanList.size(); i < size; i++)
            {
                if (firstValue.booleanValue() != booleanList.get(i).booleanValue())
                {
                    return false;
                }
            }
            return true;
        }
    }


}
